import { createApp } from 'vue'
import App from './App.vue'
import router from './router/router.js'
import pinia from './store'
import useElementPlusIcons from './utils/use-element-plus-icons'
import '@/assets/global.css'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import axios from "axios";
import DisplayChart from './views/chart/DisplayChart.vue'

createApp(DisplayChart).mount('#app')
// Make App Instance
const app = createApp(App)

// 获取要挂载的元素
const mountEl = document.querySelector('#app')

// 如果元素上已经有Vue应用，先卸载
if (mountEl.__vue_app__) {
    mountEl.__vue_app__.unmount()
}


// Use Router
app.use(router)

// Use Element Plus
app.use(ElementPlus)

// Use Element Plus
useElementPlusIcons(app)

// Use Pinia
app.use(pinia)

app.mount('#app')

app.config.errorHandler = (err, instance, info) => {
    console.error('Global Vue Error:', err, info);
};

const api = axios.create({
    baseURL: 'http://localhost:8888/videoRank/loadDataList', // 替换为您的后端地址
    timeout: 10000
})

export default api
